import { defHttp } from "/@/utils/http/axios"
import { Modal } from "ant-design-vue"

enum Api {
  page = "/msg-push-service/msgReceiver/page",
  get = "/msg-push-service/msgReceiver/get",
  save = "/msg-push-service/msgReceiver/save",
  edit = "/msg-push-service/msgReceiver/update",
  sendCaptcha = "/msg-push-service/msgReceiver/sendCaptcha",
  checkCaptcha = "/msg-push-service/msgReceiver/checkCaptchaFromAdmin",
  getWxMpQrcode = "/msg-push-service/msgReceiver/getWxMpQrcode",

  listSubscribeMsg = "/msg-push-service/msgReceiver/listSubscribeMsg",
}

/**
 * 列表
 * @param params
 */
export const pageReceiver = (params) => defHttp.get({ url: Api.page, params })
export const getReceiver = (params) => defHttp.get({ url: Api.get, params })
export const sendCaptcha = (params) => defHttp.post({ url: Api.sendCaptcha, params })
export const checkCaptcha = (params) => defHttp.post({ url: Api.checkCaptcha, params })

/**
 * 保存或者更新消息接收人
 * @param params
 */
export const saveOrUpdateReceiver = (params, isUpdate) => {
  const url = isUpdate ? Api.edit : Api.save
  return defHttp.post({ url: url, params })
}

export const listSubscribeMsg = (params) => defHttp.get({ url: Api.listSubscribeMsg, params })
export const getWxMpQrcode = () => defHttp.get({ url: Api.getWxMpQrcode, params: {} })
